<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cmcc.resource.*"%>
<%@include file="../checkLoginSession.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%
	String flag = request.getParameter("flag");
	System.out.println("checkAddResource.jsp ------------ flag = "
			+ flag);
	if (flag == null || !flag.equals("submitresource")) {
		return;
	}
	String start = request.getParameter("begin");
	String end = request.getParameter("end");
	String num_type = request.getParameter("num_type");
	System.out.println("checkAddResource.jsp ------------ start = "
			+ start);
	System.out
			.println("checkAddResource.jsp ------------ end = " + end);
	System.out
			.println("checkAddResource.jsp ------------ number_type = "
					+ num_type);
					
	if (start == null || start.trim().length() < 11 || end == null
			|| end.trim().length() < 11 || num_type == null) {
		%>
			<br><br><br><br>
			<h2 align="center">
				<font color="red">
					信息填写错误！
				</font>
			</h2>	
			
			<h3 align="center">
				<a href="javascript:history.back()">返回</a>
			</h3>
		<%
		return;
	}
		long long_start = Long.parseLong(start.trim());
		long long_end = Long.parseLong(end.trim());
		if(long_start>long_end){
			long t;
			t = long_start;
			long_start = long_end;
			long_end = t;
		}
		if(long_end-long_start>100){
			%>
				<br><br><br><br>
				<h2 align="center">
					<font color="red">
						信息填写错误！
					</font>
				</h2>	
				
				<h3 align="center">
					<a href="javascript:history.back()">返回</a>
				</h3>
			<%
			return;
		}
	if (Resource.addBeginToEndBy(long_start, long_end, num_type.trim()) ) {
		System.out.println("yes");
		%>
			<br><br><br><br>
			<h2 align="center">
				<font color="red">
					添加成功！
				</font>
			</h2>	
			
			<h3 align="center">
				<a href="addResource.jsp">返回</a>
			</h3>
		<%
		 
	} else {
		System.out.println("No");
		%>
			<br><br><br><br>
			<h2 align="center">
				<font color="red">
					添加失败，请稍后再试！
				</font>
			</h2>	
			
			<h3 align="center">
				<a href="javascript:history.back()">返回</a>
			</h3>
		<%
		
	}
%>
 